import {
  Toast,
  Dialog
} from "vant";
import cTitle from "components/title";
import {
  scrollMixin
} from "../../../utils/mixin";
export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      list: [
        {
          mobile: '13111111111',
          password: '123123',
          uid: '94820',
          username: '13*******11',
          avatar: 'https://shops.cg500.com/static/images/photo-mr.jpg'
        },
        {
          mobile: '13111111199',
          password: '123123',
          uid: '95654',
          username: '13*******99',
          avatar: 'https://shops.cg500.com/static/images/photo-mr.jpg'
        },
        {
          mobile: '15584451495',
          password: '123123',
          uid: '96284',
          username: '15*******95',
          avatar: 'https://shops.cg500.com/static/images/photo-mr.jpg'
        }
      ],
      isLoadMore: true,
      page: 1,
      total_page: 0,
      uid: '',
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log('active')
    if (!localStorage.getItem("uid")) {
      this.$router.push(this.fun.getUrl("login"));
      return
    }
    this.uid = localStorage.getItem("uid")
    this.getList();
    // this.list = localStorage.getItem("niuniuLoginList") ? JSON.parse(localStorage.getItem("niuniuLoginList")) : []
  },
  computed: {

  },
  methods: {
     // 跳转页面--牛牛商城-89
     GotoNewPage(url){
      this.$router.push(this.fun.getUrl(url));
    },
    // 退出
    loginout(item){
      console.log(item,'退出')
      Dialog.confirm({
        title: "提示",
        message: "确定退出绑定?"
      })
        .then(() => {
         console.log('确定退出')
         this.delAccount(item.id)
        })
        .catch(() => {
          console.log('取消')
        })
    },
    delAccount(id){
      $http.post("NiuTwo.zhanghao_del", {
        id: id
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'shuju_list')
          Toast("退出成功");
          this.getList();
        } else {
          Toast(res.msg);
        }
      });
    },
    mobile_login(item) {
      
      if (this.fun.isTextEmpty(item.zhanghao)) {
        Toast("请填写手机号");
        return;
      }
      if (this.fun.isTextEmpty(item.mima)) {
        Toast("请填写密码");
        return;
      }
      this.login(item);
    },
    getList() {
      $http.get("NiuTwo.zhanghao_list", {
        uid: localStorage.getItem("uid")
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'shuju_list')
          
          this.list = res.data
        } else {
          
        }
      });
    },
    async login(data) { //登录
      console.log(data,'登陆1111111');
      let that = this;
      let url;
      let datainfo;
      let type = "";
      let loading = "正在获取";
      url = "member.login.index";
      datainfo = {
        captcha: "",
        country: "86",
        is_sms: 0,
        login_checked: false, //协议是否选中
        mid: localStorage.getItem("mid"),
        mobile: data.zhanghao,
        mobileErr: "",
        password: data.mima,
        passwordErr: "",
        uuid: 0,
      }
      console.log(datainfo, 'datainfodatainfodatainfo')
      $http.post(url, datainfo, loading, "", type).then(async (response) => {
        console.log(response);
        if (response.result === 1) {
          that.uid = response.msg.uid
          that.$router.push(this.fun.getUrl("member"));
        }
      });
    },
    changeTabs(index) {
      this.currentTabs = index;
      this.page = 1;
      this.list = [];
      this.getList();
    },
    openPicker() {
      this.pickerShow = true;
    },


  }
};